using System;
using Tarkin.InfrastructureLibrary.Utilities.Collections;

namespace Tarkin.InfrastructureLibrary.Core.Basic
{
    /// <summary>
    /// The Package class is the implementation of the Package metaclass class as 
    /// defined by section 10.4.1 of the Unified Modeling Language: Infrastructure 
    /// specfication (version 2.1.1, dated 07-02-06).
    /// </summary>
    /// <remarks>Tarkin classes are NOT thread-safe.</remarks>
    public class Package : NamedElement
    {

#region Private Members

        /// <summary>
        /// The set of contained types.
        /// </summary>
        private Set < Type > ownedTypes = null;

        /// <summary>
        /// The containing package.
        /// </summary>
        private Package nestingPackage = null;

        /// <summary>
        /// The set of contained packages.
        /// </summary>
        private Set < Package > nestedPackages = null;

#endregion


#region Constructors

        /// <summary>
        /// Default constructor.
        /// </summary>
        public Package ()
        { }

        /// <summary>
        /// Overloaded constructor.
        /// </summary>
        /// <param name="name">The name of the Package.</param>
        public Package ( string name ) : base ( name )
        { }

#endregion


#region Public Properties

        /// <summary>
        /// The set of contained types.
        /// </summary>
        public Set < Type > OwnedTypes
        {
            get
            {
                if ( ownedTypes == null )
                {
                    ownedTypes = new Set < Type > ();
                }

                return ownedTypes;
            }
        }

        /// <summary>
        /// The containing package.
        /// </summary>
        public Package NestingPackage
        {
            get
            {
                return nestingPackage;
            }

            set
            {
                nestingPackage = value;
            }
        }

        /// <summary>
        /// The set of contained packages.
        /// </summary>
        public Set < Package > NestedPackages
        {
            get
            {
                if ( nestedPackages == null )
                {
                    nestedPackages = new Set < Package > ();
                }

                return nestedPackages;
            }
        }

#endregion

    }
}
